<?php
/**
 * Created by 项目.
 * User: xuguopeng
 * Date: 2020-06-16
 * Time: 17:16
 */

namespace app\api\controller\v1;

use app\api\model\User as UserModel;

class User
{
    /**
     * 获取用户列表
     * @validate('PagingParameter')
     */
    public function getDataList($page,$limit,$nickname,$gender)
    {
        if($nickname) {
            $where[] = ['nickname','like','%'.$nickname.'%'];
        }
        if($gender) {
            $where[] = ['gender','eq',$gender];
        }
        $where[] = ['status', 'eq', 3];
        $query = UserModel::where($where)->order('id desc');
        $count = $query->count();
        $result = $query->page($page, $limit)->select()->toArray();
        $data['count'] = $count;
        $data['data'] = $result;
        return $data;
    }


    /**
     * 获取全部用户
     */
    public function getDataAll()
    {
       return UserModel::where('status','eq',3)->select()->toArray();
    }
}